<?php
namespace app\index\controller;
use app\common\model\Newsclass;
use app\common\model\Newsinfo;
use app\index\controller\Api as Api;
use think\Controller;
use think\Db;


class Fenxiang extends Base
{
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 分享二维码
     * @author lukui  2017-07-18
     * @return [type] [description]
     */
    public function index($fid=0)
    {

        $fenxiang_url =getHostDomain().'/index/login/register.html?puid='.$_SESSION['uid'];
        $make_qr_url ='http://pan.baidu.com/share/qrcode?w=320&h=320&url='.urlencode($fenxiang_url);
        $this->assign('fenxiang_url',$fenxiang_url);
        $this->assign('make_qr_url',$make_qr_url);
        $this->assign('seo_title','分享共赢');
        return $this->fetch();

    }

    /**
     * 封装生成二维码函数
     *
     */

    function getQrcode($url){
        /*生成二维码*/
        vendor("phpqrcode.phpqrcode");
        $data =$url;
        $level = 'L';// 纠错级别：L、M、Q、H
        $size =4;// 点的大小：1到10,用于手机端4就可以了
        $QRcode = new \QRcode();
        ob_start();
        $QRcode->png($data,false,$level,$size,2);
        $imageString = base64_encode(ob_get_contents());
        ob_end_clean();
        return "data:image/jpg;base64,".$imageString;
    }

}
